<% include("/admin/comm/header.html"){} %>

<script>
function validateForm(){
    if(isEmpty($("#appid").val())){
        $.promptBox("请填入appid", "#ffb848");
    }else if(isEmpty($("#appsecret").val())){
        $.promptBox("请填入appsecret", "#ffb848");
    }else if(isEmpty($("#mpid").val())){
        $.promptBox("请填入公众号原始ID", "#ffb848");
    /*
    }else if($("#appAESStatus").val() != 0){
        $("#appAESStatus").attr("value", "0");
        $.promptBox("暂时只能使用明文模式", "#ffb848");
    */
    }else{
        return true;
    }
}
function submit(){
    if(validateForm()){
        if("${session.user.bindStatus}"=="0" || ("${session.user.bindStatus}"!="0" && confirm("确定要重新绑定么？\r\n重绑过程中公众号将无法提供服务！！"))){
            $.post("${ctxPath}/mpp/user/bind",
                $("#userBindForm").serialize(),
                function(data){
                    if(0 == data.code){
                        alert("操作成功！！\r\n请于公众号内回复\“${@com.jadyer.seed.comm.constant.SeedConstants.MPP_BIND_TEXT}\”完成绑定");
                    }else{
                        $.promptBox(data.msg, "#ffb848");
                    }
                }
            );
        }
    }
}
</script>

<div class="c_nav">
    <div class="ti">个人资料</div>
</div>
<!--Content-->
<div class="c_content">
    <!--Table order list-->
    <table class="tab_head tab_in tab_list2" width="100%">
        <tr class="ti"><th colspan="2">个人信息</th></tr>
        <tr><th width="15%">用户名：</th><td>${session.user.username}</td></tr>
        <tr><th>平台类型：</th><td>${session.user.mptype==1 ? '微信（<a href="http://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login" target="_blank">http://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login</a>）' : session.user.mptype==2 ? 'QQ' : '未知'}</td></tr>
        <tr><th>绑解状态：</th><td>${session.user.bindStatus==0 ? '<span class="cf30 fw">未绑定</span>' : '<span class="cgre fw">已绑定</span>'}</td></tr>
        <tr><th>绑解时间：</th><td>${session.user.bindTime, dateFormat="yyyy-MM-dd HH:mm:ss"}</td></tr>
    </table>
    <!--/Table order list-->
    <form id="userBindForm">
        <table class="tab_head tab_in tab_list2" width="100%">
            <tr class="ti"><th colspan="2">公众信息</th></tr>
            <tr><th width="15%">URL：</th><td>${mpurl}</td></tr>
            <tr><th>Token：</th><td>${token}</td></tr>
            <tr><th>appid：</th><td><input class="inpte" id="appid" name="appid" value="${session.user.appid}" maxlength="32"/></td></tr>
            <tr><th>appsecret：</th><td><input class="inpte" id="appsecret" name="appsecret" value="${session.user.appsecret}" maxlength="64"/></td></tr>
            <tr><th>原始ID：</th><td><input class="inpte" id="mpid" name="mpid" value="${session.user.mpid}" maxlength="32"/></td></tr>
            <tr><th>公众号：</th><td><input class="inpte" id="mpno" name="mpno" value="${session.user.mpno}" maxlength="32"/></td></tr>
            <tr><th>公众名：</th><td><input class="inpte" id="mpname" name="mpname" value="${session.user.mpname}" maxlength="32"/></td></tr>
            <tr><th>商户号：</th><td><input class="inpte" id="mchid" name="mchid" value="${session.user.mchid}" maxlength="64"/></td></tr>
            <tr><th>商户Key：</th><td><input class="inpte" id="mchkey" name="mchkey" value="${session.user.mchkey}" maxlength="64"/></td></tr>
        </table>
        <table class="tab_head tab_in tab_list2" width="100%">
            <tr class="ti"><th colspan="3">操作</th></tr>
            <tr><td class="txt_l"><a class="btn_g" href="javascript:submit();">绑定公众号</a></td></tr>
        </table>
    </form>
</div>
<!--/Content-->

<% include("/admin/comm/footer.html"){} %>